package com.jackeysun.app_widget

import android.app.Application
import android.content.Context
import com.danikula.videocache.HttpProxyCacheServer

/**
 *   Created by sunxunchao on 2021/12/30.
 */
class App: Application() {

    companion object{
        lateinit var httpProxyCacheServer: HttpProxyCacheServer
    }


    override fun onCreate() {
        super.onCreate()
//        httpProxyCacheServer = getProxy(this)
    }
    private var proxy: HttpProxyCacheServer? = null

    fun getProxy(context: Context): HttpProxyCacheServer {
        val app: App = context.applicationContext as App
        return app.proxy ?: app.newProxy().also { app.proxy = it }
    }

    private fun newProxy(): HttpProxyCacheServer {
        return HttpProxyCacheServer(this)
    }
}